﻿namespace Bridge.Base.Converter
{
    using System;
    using Bridge.Base.Constructs;

    /// <summary>
    /// Converter interface to convert a Uri object to a Character.
    /// </summary>
    public abstract class UriConverter
    {
        /// <summary>
        /// Gets the <see cref="Character"/> <see cref="Type"/> that this converter converts to.
        /// </summary>
        /// <returns><see cref="Type"/> of <see cref="Character"/> this converts.</returns>
        public abstract Type GetCharacterType();

        public abstract Character ConvertBase(Uri uri);
    }

    /// <summary>
    /// Converter interface to convert a Uri object to a Character.
    /// </summary>
    /// <typeparam name="T"><see cref="Character"/> to convert.</typeparam>
    public abstract class UriConverter<T> : UriConverter where T : Character
    {
        /// <summary>
        /// Gets the <see cref="Character"/> <see cref="Type"/> that this converter converts to.
        /// </summary>
        /// <returns><see cref="Type"/> of <see cref="Character"/> this converts.</returns>
        public override Type GetCharacterType()
        {
            return typeof(T);
        }

        /// <summary>
        /// Converts a Uri to a character.
        /// </summary>
        /// <param name="uri"><see cref="Uri"/> to convert.</param>
        /// <returns><see cref="Character"/> converted.</returns>
        public override Character ConvertBase(Uri uri)
        {
            return Convert(uri);
        }

        /// <summary>
        /// Converts a Uri to a character.
        /// </summary>
        /// <param name="uri"><see cref="Uri"/> to convert.</param>
        /// <returns><see cref="Character"/> converted.</returns>
        public abstract T Convert(Uri uri);

        /// <summary>
        /// Returns if this converter can convert a local file.
        /// </summary>
        /// <returns>True if this converter can convert a local file Uri.</returns>
        public abstract bool ConvertsFiles();

        /// <summary>
        /// Returns if this converter can convert a web file.
        /// </summary>
        /// <returns>True if this converter can convert a web file Uri.</returns>
        public abstract bool ConvertsWebFiles();

        /// <summary>
        /// Gets the converter's name.
        /// </summary>
        /// <returns>String representing the converter's name.</returns>
        public abstract string GetConverterName();

        /// <summary>
        /// Gets the converter's description.
        /// </summary>
        /// <returns>Description of the converter.</returns>
        public abstract string GetConverterDescription();
    }
}
